user = "ypc"
password = "123"
bar = '''
1,查看
2,编辑 
3,退出
'''

def login_check(func):
    def inner():
        with open("login.txt", "r") as f:
            content = f.read().strip()
            if content == "1":
                func()
                return None  # 退出函数
        print("未登录，请先进行登录")
        input_user, input_passwd = input("请输入你的账号："), input("请输入你的密码：")
        if input_user == user and input_passwd == password:
            with open("login.txt", "w") as f:
                f.write("1")
            func()
    return inner

def select_info():  # 不需要登录就可以查看
    print('金币：10000')
    print('等级：30')

@login_check  # 需要登录才可以编辑
def update_info():
    print('修改信息')

# 初始化文件状态，如果文件不存在，则创建并初始化为未登录状态
try:
    with open("login.txt", "r") as f:
        pass
except FileNotFoundError:
    with open("login.txt", "w") as f:
        f.write("0")

while True:
    print(bar)
    result = input('请输入你的操作指令：')
    if result == "1":
        select_info()
    elif result == "2":
        update_info()
    elif result == "3":
        with open("login.txt", "w") as f:
            f.write("0")
        break
